package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-24 16:29
 * @Modified By:
 */
public class Search_704 {
    public static void main(String[] args){

    }

    public int search(int[] nums,int target){
        int left = 0;
        int right = nums.length - 1;
        int pivot;
        while (left <= right){
            pivot = (left + right) / 2;
            if (nums[pivot] == target) return pivot;
            if (target < nums[pivot]) right = pivot - 1;
            else left = pivot + 1;
        }
        return -1;
    }
}
